var path = require('path');

var Ex = require('extract-text-webpack-plugin');

var ROOT_PATH = path.resolve(__dirname, "..");

var SRC_DIR = 'src';

var config = {
    paths: {
        src: path.join(ROOT_PATH, SRC_DIR),
        out: path.join(ROOT_PATH, "build"),
        index: path.join(ROOT_PATH, SRC_DIR, 'index.js'),
        app: ['zero', 'heaven', 'react'],

    }
}


module.exports = {
    entry: {
        media: config.paths.index
    },

    output: {
        path: config.paths.out,
        filename: '[name].js'
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                // exclude: /(node_modules|bower_components)/,
                loader: ["babel-loader"]
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test: /\.scss$/,
                use: Ex.extract({
                    fallback: 'style-loader',
                    use: ['css-loader', 'sass-loader']
                })
                // loader: [
                //     'style-loader',
                //     'css-loader',
                //     'sass-loader'
                // ]
            },
            {
                test: /\.(woff|svg|eot|ttf)\??.*$/,

                loader:
                    'url-loader',
            }
        ]
    },
    plugins: [
        new Ex("media.css")

    ],
    //不能使用通用模块分离的方式， 模块分离的方式会导致编译后的文件，找不到其它工程打包的通用模块
    externals: {
        react: "React",
        zero: "{Zero:Zero}",
        heaven: "{Heaven:Heaven}"

    }
}
